package com.dianda.controller;

import com.dianda.pojo.Classmate;
import com.dianda.pojo.Classmates;
import com.dianda.pojo.ClassmatesResult;
import com.dianda.pojo.Result;
import com.dianda.service.ClassmateService;
import com.dianda.service.ClassmatesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ClassmatesController {

    @Autowired
    ClassmatesService service;

    @PostMapping("/app10/announcement/list")
    public ClassmatesResult getClassmatesList() {
        List<Classmates> list = service.getClassmatesList();
        ClassmatesResult r = new ClassmatesResult();
        if (list != null) {
            r.setSuccess(true);
            r.setMsg("成功");
            r.setList(list);
        }else{
            r.setSuccess(false);
            r.setMsg("失败");
        }
        return r;
    }
    @PostMapping("/app20/announcement/findone")
    public ClassmatesResult getClassmateByid(@RequestBody Classmates mate){
        Integer id =mate.getId();
        Classmates m1=service.findById(id);
        ClassmatesResult r=new ClassmatesResult();
        if (m1 != null) {
            r.setSuccess(true);
            r.setMsg("成功");
            r.setClassmates(m1);
        }else{
            r.setSuccess(false);
            r.setMsg("失败");
        }
        return r;
    }
}
